<template>
	<view class="content">
		<uni-status-bar v-if="insertStatusBar"></uni-status-bar>
		<view class="main_block"></view>
		<view class="fixedblock">
			<uni-status-bar v-if="insertStatusBar"></uni-status-bar>
			<view class="main_block"></view>
			<view class="main">
				<view class="left" @tap="back()"><uni-icons type="back" color="#000" size="24"></uni-icons></view>
				<view class="search">
					<text>{{ title }}</text>
				</view>
				<view class="right">
					<text @tap="go('/pages/house_property/shop/index?id=' + storeId)">进店</text>
					<image @tap="collection()" v-if="iscollection == 0" src="../../../static/star.png" mode="widthFix"></image>
					<image @tap="collection()" v-else src="../../../static/star_ed.png" mode="widthFix"></image>
					<image src="../../../static/share.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import uniStatusBar from '../uni-status-bar/uni-status-bar.vue';
import uniIcons from '../uni-icons/uni-icons.vue';

export default {
	components: {
		uniStatusBar,
		uniIcons
	},
	props: {
		title: {
			type: String,
			default: ''
		},
		storeId: {
			type: Number
		},
		goodsid: {
			type: [String, Number]
		},
		type: {
			type: [String, Number]
		},
		iscollection:{
			type: [String, Number],
			default:0
		}
	},
	data() {
		return {
			insertStatusBar: true
		};
	},
	methods: {
		go(url) {
			uni.navigateTo({
				url: url
			});
		},
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		async collection() {
			let authData = uni.getStorageSync('authData');
			if (!authData) {
				uni.showToast({
					title: '请先登录',
					icon: 'none',
					duration: 2000
				});
				setTimeout(function() {
					uni.navigateTo({
						url: '/pages/login/login'
					});
				}, 2000);
				return false;
			}
			let $res = await this.$request.post('/landed/addCollection', {
				data: {
					goods_id: this.goodsid,
					type: this.type,
					is_deleted: this.iscollection == 1 ? 1 : 0
				}
			});
			this.$emit('oncollection', { is_collection: this.iscollection == 1 ? 0 : 1 });
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	background-color: #ffffff;

	.main_block {
		width: 100%;
		height: 100upx;
	}
	.fixedblock {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
		.main {
			width: 100%;
			height: 100upx;
			box-sizing: border-box;
			padding: 0upx 160upx 0upx 150upx;
			box-shadow: 0 1px 6px #ccc;
			position: absolute;
			bottom: 0;
			left: 0;
			background-color: #ffffff;
			display: flex;
			align-items: center;
			justify-content: center;

			.left {
				font-size: $uni-font-size-base;
				position: absolute;
				left: 0;
				top: 0;
				box-sizing: border-box;
				padding-left: 10upx;
				width: 150upx;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: flex-start;

				image {
					width: 30upx;
					margin-left: 20upx;
				}
			}

			.search {
				width: 100%;
				height: 60upx;
				line-height: 60upx;
				box-sizing: border-box;
				padding: 0 10upx;
				background-color: #ffffff;
				border-radius: 10upx;
				color: $uni-text-color;
				position: relative;
				text-align: center;
				font-size: $uni-font-size-base;
			}

			.right {
				width: 230upx;
				height: 100%;
				padding: 0upx 10upx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;
				position: absolute;
				right: 0;
				top: 0;
				font-size: $uni-font-size-base;
				text {
					color: #ee0f24;
				}
				image {
					width: 40upx;
				}
			}
		}
	}
}
</style>
